home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / posix / unistd.h < prev    next >
C/C++ Source or Header  |  1994-03-24  |  24KB  |  635 lines

  1. /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    POSIX Standard: 2.10 Symbolic Constants        <unistd.h>
  21.  */
  22.  
  23. #ifndef    _UNISTD_H
  24.  
  25. #define    _UNISTD_H    1
  26. #include <features.h>
  27.  
  28. __BEGIN_DECLS
  29.  
  30. /* These may be used to determine what facilities are present at compile time.
  31.    Their values can be obtained at run time from sysconf.  */
  32.  
  33. /* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988.  */
  34. #define    _POSIX_VERSION    199009L
  35.  
  36. /* These are not #ifdef __USE_POSIX2 because they are
  37.    in the theoretically application-owned namespace.  */
  38.  
  39. #define    _POSIX2_C_VERSION    199912L    /* Invalid until 1003.2 is done.  */
  40.  
  41. /* If defined, the implementation supports the
  42.    C Language Bindings Option.  */
  43. #define    _POSIX2_C_BIND    1
  44.  
  45. /* If defined, the implementation supports the
  46.    C Language Development Utilities Option.  */
  47. #define    _POSIX2_C_DEV    1
  48.  
  49. /* If defined, the implementation supports the
  50.    Software Development Utilities Option.  */
  51. #define    _POSIX2_SW_DEV    1
  52.  
  53.  
  54. /* Get values of POSIX options:
  55.  
  56.    If these symbols are defined, the corresponding features are
  57.    always available.  If not, they may be available sometimes.
  58.    The current values can be obtained with `sysconf'.
  59.  
  60.    _POSIX_JOB_CONTROL    Job control is supported.
  61.    _POSIX_SAVED_IDS    Processes have a saved set-user-ID
  62.                and a saved set-group-ID.
  63.  
  64.    If any of these symbols is defined as -1, the corresponding option is not
  65.    true for any file.  If any is defined as other than -1, the corresponding
  66.    option is true for all files.  If a symbol is not defined at all, the value
  67.    for a specific file can be obtained from `pathconf' and `fpathconf'.
  68.  
  69.    _POSIX_CHOWN_RESTRICTED    Only the super user can use `chown' to change
  70.                    the owner of a file.  `chown' can only be used
  71.                 to change the group ID of a file to a group of
  72.                 which the calling process is a member.
  73.    _POSIX_NO_TRUNC        Pathname components longer than
  74.                    NAME_MAX generate an error.
  75.    _POSIX_VDISABLE        If defined, if the value of an element of the
  76.                 `c_cc' member of `struct termios' is
  77.                 _POSIX_VDISABLE, no character will have the
  78.                 effect associated with that element.
  79.    */
  80.  
  81. #include <posix_opt.h>
  82.  
  83.  
  84. /* Standard file descriptors.  */
  85. #define    STDIN_FILENO    0    /* Standard input.  */
  86. #define    STDOUT_FILENO    1    /* Standard output.  */
  87. #define    STDERR_FILENO    2    /* Standard error output.  */
  88.  
  89.  
  90. /* All functions that are not declared anywhere else.  */
  91.  
  92. #include <gnu/types.h>
  93.  
  94. #ifndef    ssize_t
  95. #define    ssize_t    __ssize_t
  96. #endif
  97.  
  98. #define    __need_size_t
  99. #define __need_NULL
  100. #include <stddef.h>
  101.  
  102.  
  103. /* Values for the second argument to access.
  104.    These may be OR'd together.  */
  105. #define    R_OK    4        /* Test for read permission.  */
  106. #define    W_OK    2        /* Test for write permission.  */
  107. #define    X_OK    1        /* Test for execute permission.  */
  108. #define    F_OK    0        /* Test for existence.  */
  109.  
  110. /* Test for access to NAME.  */
  111. extern int __access __P ((__const char *__name, int __type));
  112. extern int access __P ((__const char *__name, int __type));
  113.  
  114.  
  115. /* Values for the WHENCE argument to lseek.  */
  116. #ifndef    _STDIO_H        /* <stdio.h> has the same definitions.  */
  117. #define    SEEK_SET    0    /* Seek from beginning of file.  */
  118. #define    SEEK_CUR    1    /* Seek from current position.  */
  119. #define    SEEK_END    2    /* Seek from end of file.  */
  120. #endif
  121.  
  122. /* Move FD's file position to OFFSET bytes from the
  123.    beginning of the file (if WHENCE is SEEK_SET),
  124.    the current position (if WHENCE is SEEK_CUR),
  125.    or the end of the file (if WHENCE is SEEK_END).
  126.    Return the new file position.  */
  127. extern __off_t __lseek __P ((int __fd, __off_t __offset, int __whence));
  128. extern __off_t lseek __P ((int __fd, __off_t __offset, int __whence));
  129.  
  130. /* Close the file descriptor FD.  */
  131. extern int __close __P ((int __fd));
  132. extern int close __P ((int __fd));
  133.  
  134. /* Read NBYTES into BUF from FD.  Return the
  135.    number read, -1 for errors or 0 for EOF.  */
  136. extern ssize_t __read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
  137. extern ssize_t read __P ((int __fd, __ptr_t __buf, size_t __nbytes));
  138.  
  139. /* Write N bytes of BUF to FD.  Return the number written, or -1.  */
  140. extern ssize_t __write __P ((int __fd, __const __ptr_t __buf, size_t __n));
  141. extern ssize_t write __P ((int __fd, __const __ptr_t __buf, size_t __n));
  142.  
  143.  
  144. /* Create a one-way communication channel (pipe).
  145.    If successul, two file descriptors are stored in PIPEDES;
  146.    bytes written on PIPEDES[1] can be read from PIPEDES[0].
  147.    Returns 0 if successful, -1 if not.  */
  148. extern int __pipe __P ((int __pipedes[2]));
  149. extern int pipe __P ((int __pipedes[2]));
  150.  
  151. /* Schedule an alarm.  In SECONDS seconds, the process will get a SIGALRM.
  152.    If SECONDS is zero, any currently scheduled alarm will be cancelled.
  153.    The function returns the number of seconds remaining until the last
  154.    alarm scheduled would have signaled, or zero if there wasn't one.
  155.    There is no return value to indicate an error, but you can set `errno'
  156.    to 0 and check its value after calling `alarm', and this might tell you.
  157.    The signal may come late due to processor scheduling.  */
  158. extern unsigned int alarm __P ((unsigned int __seconds));
  159.  
  160. /* Make the process sleep for SECONDS seconds, or until a signal arrives
  161.    and is not ignored.  The function returns the number of seconds less
  162.    than SECONDS which it actually slept (thus zero if it slept the full time).
  163.    If a signal handler does a `longjmp' or modifies the handling of the
  164.    SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
  165.    signal afterwards is undefined.  There is no return value to indicate
  166.    error, but if `sleep' returns SECONDS, it probably didn't work.  */
  167. extern unsigned int sleep __P ((unsigned int __seconds));
  168.  
  169.  
  170. /* Suspend the process until a signal arrives.
  171.    This always returns -1 and sets `errno' to EINTR.  */
  172. extern int pause __P ((void));
  173.  
  174.  
  175. /* Change the owner and group of FILE.  */
  176. extern int __chown __P ((__const char *__file,
  177.              __uid_t __owner, __gid_t __group));
  178. extern int chown __P ((__const char *__file,
  179.                __uid_t __owner, __gid_t __group));
  180.  
  181. #ifdef    __USE_BSD
  182. /* Change the owner and group of the file that FD is open on.  */
  183. extern int __fchown __P ((int __fd,
  184.               __uid_t __owner, __gid_t __group));
  185. extern int fchown __P ((int __fd,
  186.             __uid_t __owner, __gid_t __group));
  187. #endif /* Use BSD.  */
  188.  
  189. /* Change the process's working directory to PATH.  */
  190. extern int __chdir __P ((__const char *__path));
  191. extern int chdir __P ((__const char *__path));
  192.  
  193. /* Get the pathname of the current working directory,
  194.    and put it in SIZE bytes of BUF.  Returns NULL if the
  195.    directory couldn't be determined or SIZE was too small.
  196.    If successful, returns BUF.  In GNU, if BUF is NULL,
  197.    an array is allocated with `malloc'; the array is SIZE
  198.    bytes long, unless SIZE <= 0, in which case it is as
  199.    big as necessary.  */
  200. extern char *getcwd __P ((char *__buf, size_t __size));
  201.  
  202. #ifdef    __USE_GNU
  203. /* Return a malloc'd string containing the current directory name.
  204.    If the environment variable `PWD' is set, and its value is correct,
  205.    that value is used.  */
  206. extern char *get_current_dir_name __P ((void));
  207. #endif
  208.  
  209. #ifdef    __USE_BSD
  210. /* Put the absolute pathname of the current working directory in BUF.
  211.    If successful, return BUF.  If not, put an error message in
  212.    BUF and return NULL.  BUF should be at least PATH_MAX bytes long.  */
  213. extern char *getwd __P ((char *__buf));
  214. #endif
  215.  
  216.  
  217. /* Duplicate FD, returning a new file descriptor on the same file.  */
  218. extern int __dup __P ((int __fd));
  219. extern int dup __P ((int __fd));
  220.  
  221. /* Duplicate FD to FD2, closing FD2 and making it open on the same file.  */
  222. extern int __dup2 __P ((int __fd, int __fd2));
  223. extern int dup2 __P ((int __fd, int __fd2));
  224.  
  225. /* NULL-terminated array of "NAME=VALUE" environment variables.  */
  226. extern char **__environ;
  227. extern char **environ;
  228.  
  229.  
  230. /* Replace the current process, executing PATH with arguments ARGV and
  231.    environment ENVP.  ARGV and ENVP are terminated by NULL pointers.  */
  232. extern int __execve __P ((__const char *__path, char *__const __argv[],
  233.               char *__const __envp[]));
  234. extern int execve __P ((__const char *__path, char *__const __argv[],
  235.             char *__const __envp[]));
  236.  
  237. #ifdef __USE_GNU
  238. /* Execute the file FD refers to, overlaying the running program image.
  239.    ARGV and ENVP are passed to the new program, as for `execve'.  */
  240. extern int fexecve __P ((int __fd,
  241.              char *const __argv[], char *const __envp[]));
  242.  
  243. #endif
  244.  
  245.  
  246. /* Execute PATH with arguments ARGV and environment from `environ'.  */
  247. extern int execv __P ((__const char *__path, char *__const __argv[]));
  248.  
  249. /* Execute PATH with all arguments after PATH until a NULL pointer,
  250.    and the argument after that for environment.  */
  251. extern int execle __P ((__const char *__path, __const char *__arg,...));
  252.  
  253. /* Execute PATH with all arguments after PATH until
  254.    a NULL pointer and environment from `environ'.  */
  255. extern int execl __P ((__const char *__path, __const char *__arg,...));
  256.  
  257. /* Execute FILE, searching in the `PATH' environment variable if it contains
  258.    no slashes, with arguments ARGV and environment from `environ'.  */
  259. extern int execvp __P ((__const char *__file, char *__const __argv[]));
  260.  
  261. /* Execute FILE, searching in the `PATH' environment variable if
  262.    it contains no slashes, with all arguments after FILE until a
  263.    NULL pointer and environment from `environ'.  */
  264. extern int execlp __P ((__const char *__file, ...));
  265.  
  266.  
  267. /* Terminate program execution with the low-order 8 bits of STATUS.  */
  268. extern __NORETURN void _exit __P ((int __status));
  269.  
  270.  
  271. /* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
  272.    the `_SC_*' symbols for the NAME argument to `sysconf';
  273.    and the `_CS_*' symbols for the NAME argument to `confstr'.  */
  274. #include <confname.h>
  275.  
  276. /* Get file-specific configuration information about PATH.  */
  277. extern long int __pathconf __P ((__const char *__path, int __name));
  278. extern long int pathconf __P ((__const char *__path, int __name));
  279.  
  280. /* Get file-specific configuration about descriptor FD.  */
  281. extern long int __fpathconf __P ((int __fd, int __name));
  282. extern long int fpathconf __P ((int __fd, int __name));
  283.  
  284. /* Get the value of the system variable NAME.  */
  285. extern long int __sysconf __P ((int __name));
  286. extern long int sysconf __P ((int __name));
  287.  
  288. #ifdef    __USE_POSIX2
  289. /* Get the value of the string-valued system variable NAME.  */
  290. extern size_t confstr __P ((int __name, char *__buf, size_t __len));
  291. #endif
  292.  
  293.  
  294. /* Get the process ID of the calling process.  */
  295. extern __pid_t __getpid __P ((void));
  296. extern __pid_t getpid __P ((void));
  297.  
  298. /* Get the process ID of the calling process's parent.  */
  299. extern __pid_t __getppid __P ((void));
  300. extern __pid_t getppid __P ((void));
  301.  
  302. /* Get the process group ID of process PID.  */
  303. extern __pid_t __getpgrp __P ((__pid_t __pid));
  304.  
  305. #ifndef    __FAVOR_BSD
  306. /* Get the process group ID of the calling process.  */
  307. extern __pid_t getpgrp __P ((void));
  308. #else /* Favor BSD.  */
  309. #define    getpgrp(pid)    __getpgrp(pid)
  310. #endif
  311.  
  312. /* Set the process group ID of the process matching PID to PGID.
  313.    If PID is zero, the current process's process group ID is set.
  314.    If PGID is zero, the process ID of the process is used.  */
  315. extern int __setpgrp __P ((__pid_t __pid, __pid_t __pgid));
  316. extern int setpgid __P ((__pid_t __pid, __pid_t __pgid));
  317.  
  318. #ifdef    __USE_BSD
  319. /* Set the process group of PID to PGRP.  */
  320. extern int setpgrp __P ((__pid_t __pid, __pid_t __pgrp));
  321. #endif /* Use BSD.  */
  322.  
  323. /* Create a new session with the calling process as its leader.
  324.    The process group IDs of the session and the calling process
  325.    are set to the process ID of the calling process, which is returned.  */
  326. extern __pid_t __setsid __P ((void));
  327. extern __pid_t setsid __P ((void));
  328.  
  329. /* Get the real user ID of the calling process.  */
  330. extern __uid_t __getuid __P ((void));
  331. extern __uid_t getuid __P ((void));
  332.  
  333. /* Get the effective user ID of the calling process.  */
  334. extern __uid_t __geteuid __P ((void));
  335. extern __uid_t geteuid __P ((void));
  336.  
  337. /* Get the real group ID of the calling process.  */
  338. extern __gid_t __getgid __P ((void));
  339. extern __gid_t getgid __P ((void));
  340.  
  341. /* Get the effective group ID of the calling process.  */
  342. extern __gid_t __getegid __P ((void));
  343. extern __gid_t getegid __P ((void));
  344.  
  345. /* If SIZE is zero, return the number of supplementary groups
  346.    the calling process is in.  Otherwise, fill in the group IDs
  347.    of its supplementary groups in LIST and return the number written.  */
  348. extern int __getgroups __P ((int __size, __gid_t __list[]));
  349. extern int getgroups __P ((int __size, __gid_t __list[]));
  350.  
  351. /* Set the user ID of the calling process to UID.
  352.    If the calling process is the super-user, set the real
  353.    and effective user IDs, and the saved set-user-ID to UID;
  354.    if not, the effective user ID is set to UID.  */
  355. extern int __setuid __P ((__uid_t __uid));
  356. extern int setuid __P ((__uid_t __uid));
  357.  
  358. #ifdef    __USE_BSD
  359. /* Set the real user ID of the calling process to RUID,
  360.    and the effective user ID of the calling process to EUID.  */
  361. extern int __setreuid __P ((__uid_t __ruid, __uid_t __euid));
  362. extern int setreuid __P ((__uid_t __ruid, __uid_t __euid));
  363.  
  364. /* Set the effective user ID of the calling process to UID.  */
  365. extern int seteuid __P ((__uid_t __uid));
  366. #endif /* Use BSD.  */
  367.  
  368. /* Set the group ID of the calling process to GID.
  369.    If the calling process is the super-user, set the real
  370.    and effective group IDs, and the saved set-group-ID to GID;
  371.    if not, the effective group ID is set to GID.  */
  372. extern int __setgid __P ((__gid_t __gid));
  373. extern int setgid __P ((__gid_t __gid));
  374.  
  375. #ifdef    __USE_BSD
  376. /* Set the real group ID of the calling process to RGID,
  377.    and the effective group ID of the calling process to EGID.  */
  378. extern int __setregid __P ((__gid_t __rgid, __gid_t __egid));
  379. extern int setregid __P ((__gid_t __rgid, __gid_t __egid));
  380.  
  381. /* Set the effective group ID of the calling process to GID.  */
  382. extern int setegid __P ((__gid_t __gid));
  383. #endif /* Use BSD.  */
  384.  
  385.  
  386. /* Clone the calling process, creating an exact copy.
  387.    Return -1 for errors, 0 to the new process,
  388.    and the process ID of the new process to the old process.  */
  389. extern __pid_t __fork __P ((void));
  390. extern __pid_t fork __P ((void));
  391.  
  392. #ifdef    __USE_BSD
  393. /* Clone the calling process, but without copying the whole address space.
  394.    The the calling process is suspended until the the new process exits or is
  395.    replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
  396.    and the process ID of the new process to the old process.  */
  397. extern __pid_t __vfork __P ((void));
  398. extern __pid_t vfork __P ((void));
  399. #endif /* Use BSD. */
  400.  
  401.  
  402. /* Return the pathname of the terminal FD is open on, or NULL on errors.
  403.    The returned storage is good only until the next call to this function.  */
  404. extern char *ttyname __P ((int __fd));
  405.  
  406. /* Return 1 if FD is a valid descriptor associated
  407.    with a terminal, zero if not.  */
  408. extern int __isatty __P ((int __fd));
  409. extern int isatty __P ((int __fd));
  410.  
  411.  
  412. /* Make a link to FROM named TO.  */
  413. extern int __link __P ((__const char *__from, __const char *__to));
  414. extern int link __P ((__const char *__from, __const char *__to));
  415.  
  416. #ifdef    __USE_BSD
  417. /* Make a symbolic link to FROM named TO.  */
  418. extern int __symlink __P ((__const char *__from, __const char *__to));
  419. extern int symlink __P ((__const char *__from, __const char *__to));
  420.  
  421. /* Read the contents of the symbolic link PATH into no more than
  422.    LEN bytes of BUF.  The contents are not null-terminated.
  423.    Returns the number of characters read, or -1 for errors.  */
  424. extern int __readlink __P ((__const char *__path, char *__buf, size_t __len));
  425. extern int readlink __P ((__const char *__path, char *__buf, size_t __len));
  426. #endif /* Use BSD.  */
  427.  
  428. /* Remove the link NAME.  */
  429. extern int __unlink __P ((__const char *__name));
  430. extern int unlink __P ((__const char *__name));
  431.  
  432. /* Remove the directory PATH.  */
  433. extern int __rmdir __P ((__const char *__path));
  434. extern int rmdir __P ((__const char *__path));
  435.  
  436.  
  437. /* Return the foreground process group ID of FD.  */
  438. extern __pid_t tcgetpgrp __P ((int __fd));
  439.  
  440. /* Set the foreground process group ID of FD set PGRP_ID.  */
  441. extern int tcsetpgrp __P ((int __fd, __pid_t __pgrp_id));
  442.  
  443.  
  444. /* Return the login name of the user.  */
  445. extern char *getlogin __P ((void));
  446.  
  447. #ifdef    __USE_BSD
  448. /* Set the login name returned by `getlogin'.  */
  449. extern int setlogin __P ((__const char *__name));
  450. #endif
  451.  
  452.  
  453. #ifdef    __USE_POSIX2
  454. /* Process the arguments in ARGV (ARGC of them, minus
  455.    the program name) for options given in OPTS.
  456.  
  457.    If `opterr' is zero, no messages are generated
  458.    for invalid options; it defaults to 1.
  459.    `optind' is the current index into ARGV.
  460.    `optarg' is the argument corresponding to the current option.
  461.    Return the option character from OPTS just read.
  462.    Return -1 when there are no more options.
  463.    For unrecognized options, or options missing arguments,
  464.    `optopt' is set to the option letter, and '?' is returned.
  465.  
  466.    The OPTS string is a list of characters which are recognized option
  467.    letters, optionally followed by colons, specifying that that letter
  468.    takes an argument, to be placed in `optarg'.
  469.  
  470.    If a letter in OPTS is followed by two colons, its argument is optional.
  471.    This behavior is specific to the GNU `getopt'.
  472.  
  473.    The argument `--' causes premature termination of argument scanning,
  474.    explicitly telling `getopt' that there are no more options.
  475.  
  476.    If OPTS begins with `--', then non-option arguments
  477.    are treated as arguments to the option '\0'.
  478.    This behavior is specific to the GNU `getopt'.  */
  479. extern int getopt __P ((int __argc, char *__const * __argv,
  480.             __const char *__opts));
  481. extern int opterr;
  482. extern int optind;
  483. extern int optopt;
  484. extern char *optarg;
  485. #endif
  486.  
  487.  
  488. #ifdef    __USE_BSD
  489.  
  490. /* Put the name of the current host in no more than LEN bytes of NAME.
  491.    The result is null-terminated if LEN is large enough for the full
  492.    name and the terminator.  */
  493. extern int __gethostname __P ((char *__name, size_t __len));
  494. extern int gethostname __P ((char *__name, size_t __len));
  495.  
  496. /* Set the name of the current host to NAME, which is LEN bytes long.
  497.    This call is restricted to the super-user.  */
  498. extern int sethostname __P ((__const char *__name, size_t __len));
  499.  
  500. /* Return the current machine's Internet number.  */
  501. extern long int gethostid __P ((void));
  502.  
  503. /* Set the current machine's Internet number to ID.
  504.    This call is restricted to the super-user.  */
  505. extern int sethostid __P ((long int __id));
  506.  
  507.  
  508. /* Return the number of bytes in a page.  This is the system's page size,
  509.    which is not necessarily the same as the hardware page size.  */
  510. extern size_t __getpagesize __P ((void));
  511. extern size_t getpagesize __P ((void));
  512.  
  513.  
  514. /* Return the maximum number of file descriptors
  515.    the current process could possibly have.  */
  516. extern int __getdtablesize __P ((void));
  517. extern int getdtablesize __P ((void));
  518.  
  519.  
  520. /* Truncate FILE to LENGTH bytes.  */
  521. extern int truncate __P ((__const char *__file, __off_t __length));
  522.  
  523. /* Truncate the file FD is open on to LENGTH bytes.  */
  524. extern int ftruncate __P ((int __fd, __off_t __length));
  525.  
  526.  
  527. /* Make all changes done to FD actually appear on disk.  */
  528. extern int fsync __P ((int __fd));
  529.  
  530. /* Make all changes done to all files actually appear on disk.  */
  531. extern int sync __P ((void));
  532.  
  533.  
  534. /* Revoke access permissions to all processes currently communicating
  535.    with the control terminal, and then send a SIGHUP signal to the process
  536.    group of the control terminal.  */
  537. extern int vhangup __P ((void));
  538.  
  539.  
  540. /* Turn accounting on if NAME is an existing file.  The system will then write
  541.    a record for each process as it terminates, to this file.  If NAME is NULL,
  542.    turn accounting off.  This call is restricted to the super-user.  */
  543. extern int acct __P ((__const char *__name));
  544.  
  545. /* Make PATH be the root directory (the starting point for absolute paths).
  546.    This call is restricted to the super-user.  */
  547. extern int chroot __P ((__const char *__path));
  548.  
  549. /* Make the block special device PATH available to the system for swapping.
  550.    This call is restricted to the super-user.  */
  551. extern int swapon __P ((__const char *__path));
  552.  
  553. /* Reboot or halt the system.  */
  554. extern int reboot __P ((int __howto));
  555.  
  556.  
  557. /* Successive calls return the shells listed in `/etc/shells'.  */
  558. extern char *getusershell __P ((void));
  559. extern void endusershell __P ((void)); /* Discard cached info.  */
  560. extern void setusershell __P ((void)); /* Rewind and re-read the file.  */
  561.  
  562.  
  563. /* Prompt with PROMPT and read a string from the terminal without echoing.
  564.    Uses /dev/tty if possible; otherwise stderr and stdin.  */
  565. extern char *getpass __P ((const char *__prompt));
  566.  
  567. #endif /* Use BSD.  */
  568.  
  569.  
  570. #ifdef __USE_MISC
  571.  
  572. /* Generate a unique temporary file name from TEMPLATE.
  573.    The last six characters of TEMPLATE must be "XXXXXX";
  574.    they are replaced with a string that makes the file name unique.
  575.    Returns TEMPLATE, or a null pointer if it cannot get a unique file name.  */
  576. extern char *mktemp __P ((char *__template));
  577.  
  578. /* Generate a unique temporary file name from TEMPLATE.
  579.    The last six characters of TEMPLATE must be "XXXXXX";
  580.    they are replaced with a string that makes the filename unique.
  581.    Returns a file descriptor open on the file for reading and writing,
  582.    or -1 if it cannot create a uniquely-named file.  */
  583. extern int mkstemp __P ((char *__template));
  584.  
  585.  
  586. /* Invoke `system call' number SYSNO, passing it the remaining arguments.
  587.    This is completely system-dependent, and not often useful.
  588.  
  589.    In Unix, `syscall' sets `errno' for all errors and most calls return -1
  590.    for errors; in many systems you cannot pass arguments or get return
  591.    values for all system calls (`pipe', `fork', and `getppid' typically
  592.    among them).
  593.  
  594.    In Mach, all system calls take normal arguments and always return an
  595.    error code (zero for success).  */
  596. extern int syscall __P ((int __sysno, ...));
  597.  
  598. #endif    /* Use misc.  */
  599.  
  600.  
  601. #if defined (__USE_MISC) && !defined (F_LOCK)
  602. /* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
  603.    files consistent.  Some systems have them there and some here, and some
  604.    software depends on the macros being defined without including both.  */
  605.  
  606. /* `lockf' is a simpler interface to the locking facilities of `fcntl'.
  607.    LEN is always relative to the current file position.
  608.    The CMD argument is one of the following.  */
  609.  
  610. #define F_ULOCK 0       /* Unlock a previously locked region.  */
  611. #define F_LOCK  1       /* Lock a region for exclusive use.  */ 
  612. #define F_TLOCK 2       /* Test and lock a region for exclusive use.  */
  613. #define F_TEST  3       /* Test a region for other processes locks.  */
  614.  
  615. extern int lockf __P ((int __fd, int __cmd, __off_t __len));
  616. #endif /* Use misc and F_LOCK not already defined.  */
  617.  
  618.  
  619. #ifdef __USE_GNU
  620.  
  621. /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
  622.    set to EINTR.  */
  623.  
  624. #define TEMP_FAILURE_RETRY(expression) \
  625.   ({ long int __result;                                  \
  626.        do __result = (long int) (expression);                      \
  627.        while (__result == -1L && errno == EINTR);                  \
  628.        __result; })
  629.           
  630. #endif
  631.  
  632. __END_DECLS
  633.  
  634. #endif /* unistd.h  */
  635.